package ltd.viewpager.interpolator;

import android.view.animation.Interpolator;

/**
 * Created by chinalin on 2017/5/6.
 */

public class WorkspaceOvershootInterpolator implements Interpolator {
    private static final float DEFAULT_TENSION = 1.3f;
    private float mTension;

    public WorkspaceOvershootInterpolator() {
        mTension = DEFAULT_TENSION;
    }

    public void setDistance(int distance) {
        mTension = distance > 0 ? DEFAULT_TENSION / distance
                : DEFAULT_TENSION;
    }

    public void disableSettle() {
        mTension = 0.f;
    }

    public float getInterpolation(float t) {
        t -= 1.0f;
        return t * t * ((mTension + 1) * t + mTension) + 1.0f;
    }
}
